﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="AsStringEqualityComparer.cs" company="JDML Consulting Ltd.">
//   Copyright 2011 Photon Project - http://photon.codeplex.com
// </copyright>
// <summary>
//   Defines the AsStringEqualityComparer type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Photon.Assets
{
    using System.Collections.Generic;

    public class AsStringEqualityComparer : IEqualityComparer<object>
    {
        bool IEqualityComparer<object>.Equals(object x, object y)
        {
            if (ReferenceEquals(x, y))
            {
                return true;
            }

            if (ReferenceEquals(x, null) || ReferenceEquals(y, null))
            {
                return false;
            }

            return x.ToString() == y.ToString();
        }

        public int GetHashCode(object obj)
        {
            return obj == null ? 0 : obj.ToString().GetHashCode();
        }
    }
}